import { createSlice } from '@reduxjs/toolkit'

const initialState = {
    start: '北京',
    end: '上海',
    date: '2025-12-25',
    isSpeed: true,
    isSeat: true,
    isDesc: true
}

const citySlice = createSlice({
    name: 'city',
    initialState,
    reducers: {
        cityExchange(state, action) {
            const cache = state.start;
            state.start = state.end;
            state.end = cache;
        },
        citySetIsSpeed(state, action) {
            state.isSpeed = action.payload
        },
        citySetDate(state, action) {
            state.date = action.payload
        }
    },
})

// Action creators are generated for each case reducer function
export const { cityExchange, citySetIsSpeed, citySetDate } = citySlice.actions

export default citySlice.reducer